package response;

import java.util.Iterator;

import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.validation.BindingResult;

/**
 * Created by ace on 2017/8/23.
 */
public class BaseResponse {
	private int Code = 200;
	private String msg;
	//private String exception;



	public BaseResponse(int Code, BindingResult result) {
		super();
		this.Code = Code;
		
		StringBuffer sb = new StringBuffer();
			result.getAllErrors().stream().forEach((op) -> {
				DefaultMessageSourceResolvable ds=(DefaultMessageSourceResolvable) op.getArguments()[0];
				sb.append("【错误信息】"+ds.getDefaultMessage()+"->code=" + op.getCode() + ",message=" + op.getDefaultMessage());
			
			});
		
			this.msg ="失败原因:"+sb.toString();

	}
	public BaseResponse(int Code,String msg ) {
		super();
		this.Code = Code;
		this.msg=msg;
	}



	public int getCode() {
		return Code;
	}



	public void setCode(int Code) {
		this.Code = Code;
	}



	public String getmsg() {
		return msg;
	}



	public void setmsg(String msg) {
		this.msg = msg;
	}



}
